package pres.moling.common.tool;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;

/**
 * 集合操作
 */
public interface CollHelper {

    static <T> ArrayList<T> newArrayList() {return new ArrayList<>();}

    static <T> ArrayList<T> newArrayList(int size) {return new ArrayList<>(size);}

    static boolean isNotEmpty(Object[] objects) {
        return !isEmpty(objects);
    }

    static boolean isEmpty(Object[] objects) {
        return Objects.isNull(objects) || objects.length == 0;
    }

    static <T> boolean isEmpty(Collection<T> collections) {
        return collections == null || collections.isEmpty();
    }

    static <T> boolean isNotEmpty(Collection<T> collections) {
        return !isEmpty(collections);
    }
}
